﻿using System;
using System.ComponentModel;
using System.Data;
using System.Windows;
using ReflectionStudio.Core.Events;
namespace WPFExcelReport
{
    /// <summary>
    /// Interaction logic for ProductionOrder.xaml
    /// </summary>
    public partial class UIUR : ViewBase
    {
        #region ==PROG===========
        public static readonly DependencyProperty PROGProperty = DependencyProperty.Register("PROG",
            typeof(string), typeof(UIUR),
            new FrameworkPropertyMetadata("", FrameworkPropertyMetadataOptions.BindsTwoWayByDefault, OnPROGChanged));
        public string PROG
        {
            get
            {
                return (string)GetValue(PROGProperty);
            }
            set
            {
                SetValue(PROGProperty, value);
                OnPROGChg(value);
            }
        }
        private static void OnPROGChanged(DependencyObject sender, DependencyPropertyChangedEventArgs e)
        {
            var src = sender as UIUR;
            if (src != null)
            {
                src.PROG = (string)e.NewValue;
            }
        }
        #endregion

        #region ==CONTROLS===========
        public static readonly DependencyProperty CONTROLSProperty = DependencyProperty.Register("CONTROLS",
            typeof(string), typeof(UIUR),
            new FrameworkPropertyMetadata("", FrameworkPropertyMetadataOptions.BindsTwoWayByDefault, OnCONTROLSChanged));
        public string CONTROLS
        {
            get
            {
                return (string)GetValue(CONTROLSProperty);
            }
            set
            {
                SetValue(CONTROLSProperty, value);
                OnCONTROLSChg(value);
            }
        }
        private static void OnCONTROLSChanged(DependencyObject sender, DependencyPropertyChangedEventArgs e)
        {
            var src = sender as UIUR;
            if (src != null)
            {
                src.CONTROLS = (string)e.NewValue;
            }
        }
        #endregion

        #region ==USERID===========
        public static readonly DependencyProperty USERIDProperty = DependencyProperty.Register("USERID",
            typeof(string), typeof(UIUR),
            new FrameworkPropertyMetadata("", FrameworkPropertyMetadataOptions.BindsTwoWayByDefault, OnUSERIDChanged));
        public string USERID
        {
            get
            {
                return (string)GetValue(USERIDProperty);
            }
            set
            {
                SetValue(USERIDProperty, value);
                OnUSERIDChg(value);
            }
        }
        private static void OnUSERIDChanged(DependencyObject sender, DependencyPropertyChangedEventArgs e)
        {
            var src = sender as UIUR;
            if (src != null)
            {
                src.USERID = (string)e.NewValue;
            }
        }
        #endregion

        public UIUR()
        { 
        }
        public void ResetSeq(object sender, RoutedEventArgs e)
        {

            VSDDAT.SD22.RESETSEQ("0022", "  ", "URSEQ", 1);
            ((VICC_USERRIGHT)MV).DeleteICC_USERRIGHT(null, 0);
            foreach (DataRow dwUR in TBMain.Rows)
            {
              
                dwUR["ROWNID"] = VSDDAT.SD22.GETNEXT("0022", "  ", "URSEQ", 1);
                ((VICC_USERRIGHT)MV).InsertICC_USERRIGHT(dwUR, app.company);
            }
        }
        public virtual void OnFUNCTIONChg(DataRow value)
        {

        }
        public virtual void OnUSERIDChg(string value)
        {

        }
        public virtual void OnPROGChg(string value)
        {

        }
        public virtual void OnPRGCTChg(string value)
        {

        }
        public virtual void OnCONTROLSChg(string value)
        {

        }
        public override void OnSave()
        {
            if (dwMaster == null)
                return;
            if (!IsSaved)
                return;
            //((VLIEFKO)MV).UpdateLIEFKO(dwMaster, app.company, 0);
            base.OnSave();
        }
    }
}
